<?php
class CreateIssueStep1Form extends Zend_Form
{
	public function init()
	{
		$fronController = Zend_Controller_Front::getInstance();
		$request = $fronController->getRequest();
		$projectId = $request->getParam('project');
		//$baseUrl = $request->baseUrl();
		
		$Project = new Project();
		$projectList = $Project->getList();
		
		$IssueType = new IssueType();
		$issueTypeList = $IssueType->getList();
		
		$project = $this->createElement('select','project');
		$project->setLabel('* Project:')
				->setValue($projectId)
				->setRequired(true)
				->addMultioption('','[Select]')
				->addMultioptions($projectList);
				
		$issuetype = $this->createElement('select','issuetype');
		$issuetype->setLabel('* Type:')
				->setRequired(true)
				->setAttrib('class','imagebacked issuetype_list')
				->addMultioptions($issueTypeList)
				->addMultioption('','N/A');
				
		/*for ($i = 0; $i < count($issueTypetList); $i++) {
			//echo $issueTypetList[$i]['value'];
			$issuetype->setAttrib('style',"background:url(../image/".$issueTypetList[$i]['icon_url'].")");
		}*/
				
		$next = $this->createElement('submit','next');
		$next->setLabel('Next >>')
				->setDecorators(array(
							'viewHelper',
								'Errors',
								array('Description', array('tag'=>'', 'escape'=>false)),
								array(array('data'=>'HtmlTag'),
									array('tag'=>'td', 'valign'=>'top', 'style'=> 'background-color:#ffffff;text-align:center','openOnly'=>true,'colspan'=>2,'align'=>'center')),
								//array('Label', array('tag'=>'td')),
								array(array('row'=>'HtmlTag'), array('tag'=>'tr','openOnly'=>true))
				));
				
		$cancel = $this->createElement('button','cancel');
		$cancel->setLabel('Cancel')
				->setDecorators(array(
							'viewHelper',
								'Errors',
								array('Description', array('tag'=>'', 'escape'=>false)),
								array(array('data'=>'HtmlTag'),
									array('tag'=>'td', 'valign'=>'top', 'style'=> 'background-color:#ffffff','closeOnly'=>true)),
								//array('Label', array('tag'=>'td')),
								array(array('row'=>'HtmlTag'), array('tag'=>'tr','closeOnly'=>true))
				));
				
				$this->addElements(array(
						$project,
						$issuetype,
						$next,
						$cancel
		));
		
		$this->setElementDecorators(array(
								'viewHelper',
								'Errors',
								array('Description', array('tag'=>'', 'escape'=>false)),
								array(array('data'=>'HtmlTag'),
									array('tag'=>'td', 'valign'=>'top', 'style'=> 'background-color:#ffffff;text-align:left', 'width'=>'60%')),
								array('Label', array('tag'=>'td')),
								array(array('row'=>'HtmlTag'), array('tag'=>'tr'))),
								array('project','issuetype')
								);
								
		$this->addDecorators(array(
				'FormElements',
				array('HtmlTag', array('tag' => 'table','width'=>'100%','cellspacing'=>'0','border'=>'0','class'=>'pform')),
				'Form'
		));
	}
}